package com.dingding.queue.facade;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.dingding.common.core.beans.UserTaxiOrdert;
import com.dingding.common.core.beans.special.UserspecialorderT;
import com.dingding.facade.queue.facade.IQueueFacade;
import com.dingding.facade.special.ISpecialOrderFacade;
import com.dingding.queue.queue.producer.IBusinessProducer;
import com.dingding.queue.queue.producer.IProducer;

@Component("queueFacade")
public class QueueFacadeImpl implements IQueueFacade {

	@Resource(name = "emailProducer")
	private IProducer emailProducer;

	@Resource(name = "messageProducer")
	private IProducer messageProducer;

	@Resource(name = "pushProducer")
	private IProducer pushProducer;

	@Resource(name = "nettyPushProducer")
	private IProducer nettyPushProducer;

	@Resource(name = "businessProducer")
	private IBusinessProducer businessProducer;

	@Resource(name = "appointSpecialOrderProducer")
	private IProducer appointSpecialOrderProducer;

	@Resource(name = "appointTaxiOrderProducer")
	private IProducer appointTaxiOrderProducer;

	@Resource(name = "specialOrderFacade")
	private ISpecialOrderFacade specialOrderFacade;

	/**
	 * 
	 * 添加邮件消息到队列中
	 * 
	 * @Title: addEmailToQueue
	 * @return true 添加成功 false 添加失败
	 * @author CHEHAUNBO
	 * 
	 */
	@Override
	public boolean addEmailToQueue(String content) {
		return emailProducer.send(content);
	}

	/**
	 * 
	 * 添加推送消息到队列中
	 * 
	 * @Title: addPushToQueue
	 * @return true 添加成功 false 添加失败
	 * @author CHEHAUNBO
	 * 
	 */
	@Override
	public boolean addPushToQueue(String content) {
		return pushProducer.send(content);
	}

	/**
	 * 
	 * 添加短信消息到队列中
	 * 
	 * @Title: addMessageToQueue
	 * @return true 添加成功 false 添加失败
	 * @author CHEHAUNBO
	 * 
	 */
	@Override
	public boolean addMessageToQueue(String content) {
		return messageProducer.send(content);
	}

	/**
	 * 
	 * 添加 增加推送次数到队列中
	 * 
	 * @Title: addPushNumberToQueue
	 * @return true 添加成功 false 添加失败
	 * @author CHEHAUNBO
	 * 
	 */
	@Override
	public boolean addPushNumberToQueue(String content) {
		return businessProducer.executeBusiness(content);
	}

	/**
	 * @Description:添加指派专车订单到消息队列
	 * @author fengshuonan
	 * @since 2.4
	 */
	@Override
	public boolean addSpecialOrderToQueue(UserspecialorderT userspecialorderT) {

		// 如果订单为实时订单
		if (userspecialorderT.getSetOutType() == 1) {
			return this.specialOrderFacade.appointRealOrder(userspecialorderT);
		// 如果订单为预约订单
		} else if (userspecialorderT.getSetOutType() == 2) {
			return this.specialOrderFacade.appointUnRealOrder(userspecialorderT);
		} else {
			return false;
		}
	}

	/**
	 * @Description 添加出租车订单到队列里
	 * @author fengshuonan
	 * @return boolean true 添加成功 false 添加失败
	 */
	@Override
	public boolean addTaxiOrderToQueue(UserTaxiOrdert taxiOrdert) {
		return this.specialOrderFacade.appointTaxiOrder(taxiOrdert);
	}

	/**
	 * @Description 用netty推送消息
	 * @author fengshuonan
	 */
	@Override
	public boolean addNettyPushToQueue(String pushData) {
		return this.nettyPushProducer.send(pushData);
	}

}
